<!DOCTYPE html>
<html lang="zh-cn">
	<head>
		<meta charset="utf-8"/>
		<title>車間機台設備異常公布</title>
		<meta name="viewport" content="width=device-width, initial-scale=1"/>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<!-- 引入LayUI的样式文件 -->
		<link rel="stylesheet" href="./layui/css/layui.css"/>
		<link rel="stylesheet" href="./4/lumen/bootstrap.css" media="screen"/>
		<link rel="stylesheet" href="./_assets/css/custom.min.css"/>
	</head>
	<body>
		<div class="container">
			<div class="row">
				<div class="form-group row ">
					<div class="col-sm-4">
						<input class="form-control" placeholder="筛选工序"  id="Fruit" type="text"/>
						<label><input name="Fruit" type="checkbox" value="齐纳" />齐纳 </label> 
						<label><input name="Fruit" type="checkbox" value="固晶" />固晶 </label> 
						<label><input name="Fruit" type="checkbox" value="焊线" />焊线 </label> 
						<label><input name="Fruit" type="checkbox" value="点胶" />点胶 </label> 
						<label><input name="Fruit" type="checkbox" value="切割" />切割 </label> 
						<label><input name="Fruit" type="checkbox" value="分光" />分光 </label> 
						<label><input name="Fruit" type="checkbox" value="编带" />编带 </label> 
					</div>
					<div class="col-sm-4">
						<input class="form-control" placeholder="筛选異常種類"  id="Exception_type" type="text"/>
						<label><input name="Exception_type" type="checkbox" value="点胶" />点胶 </label> 
						<label><input name="Exception_type" type="checkbox" value="切割" />切割 </label> 
						<label><input name="Exception_type" type="checkbox" value="分光" />分光 </label> 
						<label><input name="Exception_type" type="checkbox" value="编带" />编带 </label> 
						<label><input name="Exception_type" type="checkbox" value="設備故障停機" />設備故障停機 </label> 
						<label><input name="Exception_type" type="checkbox" value="品質異常停線" />品質異常停線 </label> 
						<label><input name="Exception_type" type="checkbox" value="更換耗材" />更換耗材 </label> 
					</div>
					<div class="col-sm-4">
						<input class="form-control" placeholder="筛选停機時長"  id="Stop" type="text"/>
						<label><input name="Stop" type="checkbox" value="0~1" />0~1 </label> 
						<label><input name="Stop" type="checkbox" value="1~2" />1~2 </label> 
						<label><input name="Stop" type="checkbox" value="2~3" />2~3 </label> 
						<label><input name="Stop" type="checkbox" value=">3" />>3 </label> 
					</div>
				</div>	
			</div>
			<fieldset class="layui-elem-field site-demo-button">
				<legend><big><b>异常停机</b></big></legend>
				<div class="layui-fluid layui-form layui-form-pane">
					<div id="excp" class="layui-row"></div>
				</div>
			</fieldset>
		</div>
		<!-- 载入layui模块脚本 -->
		<script src="./layui/layui.js"></script>
		<script src="./_vendor/jquery/dist/jquery.min.js"></script>
		<script src="./_vendor/popper.js/dist/umd/popper.min.js"></script>
		<script src="./_vendor/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="./_assets/js/custom.js"></script>
		<script>
			layui.use(['layer','form','element'], function(){
				//layer.msg('画面载入成功!');
				layer.msg(document.URL);
			});
			var YC = {
				 "EXC01":"首件"
				,"EXC02":"生产调机"
				,"EXC03":"更换耗材"
				,"EXC04":"日点检保养"
				,"EXC05":"冶具清理"
				,"EXC06":"工单切换调机"
				,"EXC11":"设备故障调机"
				,"EXC21":"其他计划外停机"
				,"EXC22":"待机"
			}
			var YCYY = {
				 "EXC01":"手贱"
				,"EXC02":"生产条机"
				,"EXC03":"更换耗材"
				,"EXC04":"日点检保养"
				,"EXC05":"冶具清理"
				,"EXC06":"工单切换条机"
				,"EXC11":"设备故障条机"
				,"EXC21":"其他计划外停机"
				,"EXC22":"待机"
				/*,"首件":"手贱"
				,"生产调机":"生产条机"
				,"更换耗材":"更换耗材"
				,"日点检保养":"日点检保养"
				,"冶具清理":"冶具清理"
				,"工单切换调机":"工单切换条机"
				,"设备故障调机":"设备故障条机"
				,"其他计划外停机":"其他计划外停机"*/
			}
			var BP = {
				 "BPA":"固晶"
				,"BPC":"焊线"
				,"BPD":"点胶"
				,"BPG":"切割"
				,"BPI":"分光"
				,"BPJ":"编带"
			}
			var CLASS = {
				 "B":"layui-bg-blue"
				,"C":"layui-bg-cyan"
				,"G":"layui-bg-gray"
				,"Y":"layui-bg-green"
				,"R":"layui-bg-orange"
			}
			var JT = "";
			$("input[name^='Fruit']").on('click',function(){//监听复选框
				var keys="Fruit";
				fun(keys);
			});
			$("input[name^='Exception_type']").on('click',function(){
				var keys="Exception_type";
				fun(keys);
			});
			$("input[name^='Stop']").on('click',function(){
				var keys="Stop";
				fun(keys);
			});
			function fun(keys){//获取复选框的值
				obj = document.getElementsByName(keys);
				check_val = [];
				for(k in obj){
					if(obj[k].checked)
						check_val.push(obj[k].value);
						$("#"+keys).val(check_val);
				}
			}
			setInterval(function (){
				var tempHtml = "";
				$('#excp').html("");
				$.ajax({ url: "getExcp.php",
					dataType : "json",
					success: function(data){
						if(data.length>0){
							for (var i=0;i<data.length;i++){
								if(data[i]["结束时间"] === "0000-00-00 00:00:00"){cls="layui-bg-green"}else{cls="layui-bg-gray"}
								//if(data[i]["颜色代码"] === "G"){cls="layui-bg-green"}else{cls="layui-bg-orange"}
								tempHtml+=
									"<div id='" + data[i]["异常机台"] + "d' class='layui-col-xs6 layui-col-sm4 layui-col-md4 "+CLASS[data[i]["颜色代码"]]+"'>"+
										"<fieldset id='" + data[i]["异常机台"] + "' class='layui-elem-field layui-form layui-form-pane'>"+
											"<legend>机台号: " + data[i]["异常机台"] + "</legend>"+
											"<div class='layui-field-box'>"+
												"<div class='"+cls+"'>"+
													"<br/>机台状态: " + data[i]["异常现象"] +
													"<br/>开始时间: " + data[i]["开始时间"] +
													"<br/>结束时间: " + data[i]["结束时间"] +
													"<br/>处理代码: " + data[i]["处理代码"] +
													"<br/>处理方法: " + data[i]["处理方法"] +
												"</div>"+
											"</div>"+
										"</fieldset>"+
									"</div>"
								;
							}
							$('#excp').prepend(tempHtml);//这里是JavaScript语音合成的模块
							JT = data[0]["异常机台"];
							var YY = new window.SpeechSynthesisUtterance();//设置YY是新建的语音合成对象
							YY.text ='';	//设置语音合成对象的文本
							YY.text = 
								'机台号：' + BP[JT.substr(0,3)] +'G'+ JT.substr(3,JT.length-3) +
								'，机台状态：' + data[0]["异常现象"] +  '。'
							;
							YY.lang = "zh-cn";//设置语音合成的语言
							YY.rate = 1.2;//设置语音合成的语速
							window.speechSynthesis.speak(YY);//用这个方法让YY实体化(说出来)
						}
					}
				});
			},10000)
		</script>
	</body>
</html>